package domain;

// Generated 08-ene-2009 0:57:32 by Hibernate Tools 3.2.2.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;
import org.jboss.seam.annotations.Roles;


/**
 * Mesa generated by hbm2java
 */
@Entity
@Table(name = "mesa", catalog = "irestaurant")
@Name("mesa")
@Roles({@Role(name = "table"), @Role(name = "smokingTable")})
public class Mesa implements java.io.Serializable {

	private Integer mesa;
	private Restaurante restaurante;
	private boolean permiteFumar;
	private Integer capacidad;
	private String codigo;
	private Set<Reservamesa> reservamesas = new HashSet<Reservamesa>(0);

	
	public Mesa() {
	}

	public Mesa(Restaurante restaurante, boolean permiteFumar, int capacidad,
			String codigo) {
		this.restaurante = restaurante;
		this.permiteFumar = permiteFumar;
		this.capacidad = capacidad;
		this.codigo = codigo;
	}
	public Mesa(Restaurante restaurante, boolean permiteFumar, int capacidad,
			String codigo, Set<Reservamesa> reservamesas) {
		this.restaurante = restaurante;
		this.permiteFumar = permiteFumar;
		this.capacidad = capacidad;
		this.codigo = codigo;
		this.reservamesas = reservamesas;
	}


	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "mesa", unique = true, nullable = false)
	public Integer getMesa() {
		return this.mesa;
	}

	public void setMesa(Integer mesa) {
		this.mesa = mesa;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "restaurante", nullable = false)
	public Restaurante getRestaurante() {
		return this.restaurante;
	}

	public void setRestaurante(Restaurante restaurante) {
		this.restaurante = restaurante;
	}

	@Column(name = "permiteFumar", nullable = false)
	public boolean isPermiteFumar() {
		return this.permiteFumar;
	}

	public void setPermiteFumar(boolean permiteFumar) {
		this.permiteFumar = permiteFumar;
	}

	@Column(name = "capacidad", nullable = false)
	public Integer getCapacidad() {
		return capacidad;
	}

	public void setCapacidad(Integer capacidad) {
		this.capacidad = capacidad;
	}

	@Column(name = "codigo", nullable = false, length = 10)
	public String getCodigo() {
		return codigo;
	}

	public void setCodigo(String codigo) {
		this.codigo = codigo;
	}

	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "mesa")
	public Set<Reservamesa> getReservamesas() {
		return this.reservamesas;
	}

	public void setReservamesas(Set<Reservamesa> reservamesas) {
		this.reservamesas = reservamesas;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((mesa == null) ? 0 : mesa.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Mesa other = (Mesa) obj;
		if (mesa == null) {
			if (other.mesa != null)
				return false;
		} else if (!mesa.equals(other.mesa))
			return false;
		return true;
	}

	

}
